package com.example.activitysys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.activitysys.entity.LostItem;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 失物招领Mapper接口
 */
@Mapper
public interface LostItemMapper extends BaseMapper<LostItem> {
    
    /**
     * 按地点统计失物数量
     */
    @Select("SELECT location, COUNT(*) as count FROM lost_item WHERE deleted = 0 GROUP BY location ORDER BY count DESC LIMIT 5")
    List<Map<String, Object>> selectLostCountByLocation();
    
    /**
     * 按分类统计失物数量
     */
    @Select("SELECT category, COUNT(*) as count FROM lost_item WHERE deleted = 0 GROUP BY category ORDER BY count DESC")
    List<Map<String, Object>> selectLostCountByCategory();
}